﻿using Ewell.BizComponent.UI.Core.VievModel;
using Ewell.BizComponent.UI.Reserve.ViewModel;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using static MaterialDesignThemes.Wpf.Theme;

namespace Ewell.BizComponent.UI.Reserve.Views
{
    /// <summary>
    /// EncounterReserve.xaml 的交互逻辑
    /// </summary>
    public partial class EncounterReserveView : UserControl
    {
        public EncounterReserveVm encounterReserveVm { get; set; }
        public EncounterReserveView()
        {
            InitializeComponent();
        }

        private void DataGrid_MouseLeftButtonUp(object sender, MouseButtonEventArgs e)
        {
            var dataGrid=sender as System.Windows.Controls.DataGrid;
            if (dataGrid.SelectedItem != null)
            {
                PatientVm selectedRow = (PatientVm)dataGrid.SelectedItem;
                if ((this.DataContext as EncounterReserveVm).patientBannerVm == null) (this.DataContext as EncounterReserveVm).patientBannerVm = new PatientBanner.ViewModel.PatientBannerVm();
                (this.DataContext as EncounterReserveVm).patientBannerVm.patientVm = selectedRow;
                (this.DataContext as EncounterReserveVm).outpReserveVm.patientVm = selectedRow;
                (this.DataContext as EncounterReserveVm).patiListVisib = Visibility.Collapsed;
            }
        }

        private void DataGrid_PreviewKeyDown(object sender, KeyEventArgs e)
        {
            if(e.Key == Key.Enter)
            {
                var dataGrid = sender as System.Windows.Controls.DataGrid;
                if (dataGrid.SelectedItem != null)
                {
                    PatientVm selectedRow = (PatientVm)dataGrid.SelectedItem;
                    if ((this.DataContext as EncounterReserveVm).patientBannerVm == null) (this.DataContext as EncounterReserveVm).patientBannerVm = new PatientBanner.ViewModel.PatientBannerVm();
                    (this.DataContext as EncounterReserveVm).patientBannerVm.patientVm = selectedRow;
                    (this.DataContext as EncounterReserveVm).outpReserveVm.patientVm = selectedRow;
                    (this.DataContext as EncounterReserveVm).patiListVisib = Visibility.Collapsed;
                }
            }
        }
    }
}
